﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using FRL.DebtChased.Silverlight.Extensions;

namespace FRL.DebtChased.Silverlight.Controls
{

	/// <summary>
	/// Declaration of PathButton class
	/// </summary>
	public partial class PathButton : UserControl
	{

		/////////////////////////////////////////////////////////////
		// Delegates and events

		public event EventHandler Click;

		/////////////////////////////////////////////////////////////
		// Enumerations

		public enum eImage
		{
			Arrow,
			Delete,
			Copy,
			Call,
			Add,
			RequestModification
		};

		/////////////////////////////////////////////////////////////
		// Attributes

		private eImage m_Image;
		public eImage Image
		{
			get { return m_Image; }
			set 
			{

				m_Image = value;
				switch (m_Image)
				{
					case eImage.Arrow:
						MainButton.Style = Resources["ArrowStyle"] as Style;
						break;
					case eImage.Delete:
						MainButton.Style = Resources["DeleteStyle"] as Style;
						break;
					case eImage.Copy:
						MainButton.Style = Resources["CopyStyle"] as Style;
						break;
					case eImage.Call:
						MainButton.Style = Resources["CallStyle"] as Style;
						break;
					case eImage.Add:
						MainButton.Style = Resources["AddStyle"] as Style;
						break;
					case eImage.RequestModification:
						MainButton.Style = Resources["RequestModificationStyle"] as Style;
						break;
				} // switch

			}

		}

		private bool m_bIsUpsideDown = true;
		public bool IsUpsideDown
		{
			get { return m_bIsUpsideDown; }
			set
			{

				m_bIsUpsideDown = value;
				if (m_bIsUpsideDown)
					spinTurnUpsideDown.Begin();
				else
					spinTurnRightWayUp.Begin();

			}

		}

		/////////////////////////////////////////////////////////////
		// Construction

		public PathButton()
		{

			// Load xaml resources
			InitializeComponent();

		}

		/////////////////////////////////////////////////////////////
		// Events

		private void MainButton_Click(object sender, RoutedEventArgs e)
		{

			// Fire expnd event
			if (Click != null)
				Click(this, e);

		}

		private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
		{

			// Set rotation center
			rotateTransform.CenterX = (e.NewSize.Width / 2);
			rotateTransform.CenterY = (e.NewSize.Height / 2);

		}

	}

}
